package day_2022_9_to_12.Day;

/**
 * @author haomin
 * @date 2022/09/05 23:13
 **/
public class Day3_8_Offer56_Ⅱ_SingleNumber {
    class Solution {
        public int singleNumber(int[] nums) {
            int[] data = new int[32];
            for(int i = 0; i < nums.length;++i){
                for(int j = 0; j < 32; ++j){
                    data[j] += (nums[i] >> j & 1) == 1 ? 1 : 0;
                }
            }
            int res = 0;
            for(int i = 31; i >= 0; --i){
                res = res << 1;
                if(data[i] % 3 == 1) res = (res | 1);
            }
            return res;
        }
    }
}